package com.cyy.cn.service;


import java.util.Map;


import com.cyy.cn.dao.ArticleSearchDao;
import com.cyy.cn.pojo.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import util.IdWorker;


/**
 * article服务层
 * 
 * @author Administrator
 *
 */
@Service
public class ArticleSearchService {

	@Autowired
	private ArticleSearchDao articleSearchDao;
	
	@Autowired
	private IdWorker idWorker;

	/**
	 * 增加文章
	 * @param article
	 */
	public void add(Article article){
		articleSearchDao.save(article);
	}

	/**
	 * 文章标题模糊搜索
	 * @param keywords
	 * @param page
	 * @param size
	 * @return
	 */
	public Page<Article> findByTitleLike(String keywords,int page,int size){
		PageRequest pageRequest = PageRequest.of(page-1,size);
		return articleSearchDao.findByTitleOrContentLike(keywords,keywords,pageRequest);
	}
}
